package com.spring.learn.springboot.learn02;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * Created by bgt on 2018/4/30.
 * Bean后置处理器
 */
public class BeanPost implements BeanPostProcessor {

    /**
     * 在bean对象装载完毕  依赖也已经处理完毕 即@autowired这种生效 但是未执行init方法之前
     * @param bean
     * @param beanName
     * @return
     * @throws BeansException
     */
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    /**
     * 执行init后执行
     * @param bean
     * @param beanName
     * @return
     * @throws BeansException
     */
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }
}
